package com.zdb.demo.design.pattern.behavioral.iterator.demo1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class CourseAggregateImpl implements CourseAggregate {

    private List<Course> list = new ArrayList<>();

    @Override
    public void addCourse(Course course) {
        list.add(course);
    }

    @Override
    public void removeCourse(Course course) {
        list.remove(course);
    }

    @Override
    public CourseIterator courseIterator() {
        List<Course> dest = new ArrayList<>(list);
        return new CourseIteratorImpl(dest);
    }
}
